#include <cmath>
#include <boost/lexical_cast.hpp>
#include <boost/bind.hpp>
#include <ctime>
#include <iostream>
#include <string>
#include <vector>
#include <function2d.h>

/*
usage :
  ./test function_equation startX stopX step Predicted_min predicted_max
*/
class CIsSpace : public std::unary_function<char, bool>
{
public:
  bool operator()(char c) const
  {
      return std::isspace<char>(c, std::locale());
  }
};
template <class Pred=CIsSpace>
class Tokenizer
{
public:
    static void Tokenize(std::vector<std::string>& roResult, std::string const& rostr, 
                       Pred const& roPred=Pred())
    {
        roResult.clear();
        std::string::const_iterator it = rostr.begin();
        std::string::const_iterator itTokenEnd = rostr.begin();
        while(it != rostr.end())
        {
            while(roPred(*it))
            it++;
            //itTokenEnd = std::find_if(it, rostr.end(), roPred);
            if(it < itTokenEnd)
                roResult.push_back(std::string(it, itTokenEnd));
            it = itTokenEnd;
            }
    }
};
bool parseCommandLine(const int & argc , char** argv, std::vector<std::string > * vec )
{
    if ( argc == 1 ) 
        return false; 
    if ( argc == 2 ) 
    {
        Tokenizer<>::Tokenize(*vec,std::string(argv[1]));
        return true ; 
    }
    for ( int i=1;i<argc;++i) 
    {
        vec->push_back(std::string(argv[i]));
    }
    return true ; 
};
bool compareDouble( const double & d1, const double & d2, const double & epsilon ) 
{
    return (fabs(d1 - d2) < epsilon) ? true : false ; 
};
int main(int argc, char** argv)
{
    std::vector<std::string> toRet ;
    if ( argc == 2 ) 
    {
        // launched with " ". Tokenize
        ;
    }
    CoreLib::MathLib::Function2D fun ( "sin(x)");
    for ( int i = 0 ; i < 10000 ; ++i )
        fun(3.14/2);
    int i = 0;
    i++;
};